Skip to content

feat(l2): monitor for ethrex L2 #3410

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 60 commits into from
Jul 10, 2025
Merged

feat(l2): monitor for ethrex L2 #3410

merged 60 commits into from
Jul 10, 2025

Conversation

ilitteri
Copy link
Contributor

@ilitteri ilitteri commented Jun 30, 2025

Description

This PR introduces de ethrex monitor. A currently optional tool for node operators to monitor the L2 state.

The node can be monitored in two different tabs, the Overview tab and the Logs tab. Both tabs have a help text line at the bottom to let know the user how to interact with the current tab.

The Overview tab is composed of:

  • An ASCII ethrex logo.
  • A node status widget
  • A general chain status widget, which lists:
    • Current batch (the batch being built by the Sequencer).
    • Current block (the block being built by the Sequencer).
    • Last committed batch.
    • Last committed block.
    • Last verified batch.
    • Last verified block.
  • An L2 batches widget, which lists the last 50 L2 batches and their current status, highlighting:
    • L2 batch number.
    • Number of blocks in the batch.
    • Number of L2 to L1 messages in the batch.
    • Commit tx hash (if committed).
    • Verify tx hash (if verified).
  • An L2 blocks widget, which lists the last 50 L2 blocks, highlighting:
    • L2 block number.
    • Number of txs in the block.
    • L2 block hash.
    • L2 block coinbase (probably more relevant in based rollups).
    • Gas consumed.
    • Blob gas consumed.
    • Size of the block.
  • A mempool widget, which lists the current 50 txs in the memool, highlighting:
    • Tx type (e.g. EIP1559, Privilege, etc).
    • Tx hash.
    • Tx sender.
    • Tx nonce.
  • An L1 to L2 messages widget, which lists the last 50 L1 to L2 msgs and their status, highlighting:
    • Message kind (e.g. deposit, message, etc).
    • Message status (e.g. Processed on L2, etc).
    • Message L1 tx hash.
    • Message L2 tx hash
    • Value
  • An L2 to L1 messages widget, which lists the last 50 L2 to L1 msgs and their status, highlighting:
    • Message kind (e.g. withdrawal, message, etc).
    • Message status (e.g. initiated, claimed, sent, delivered).
    • Receiver on L1.
    • Token L1 (if ERC20 withdrawal).
    • Token L2 (if ERC20 withdrawal).
    • L2 tx hash
    • Value

The Logs tab shows the logs altogether or by crate. The log level could also be adjusted in runtime.

Note

  1. This feature is introduced as optional for now given its initial state. Once mature enough, it will be default for operators.
  2. This initial version has some minor known flaws, but they were skipped in this PR on purpose:

How to test

  1. Add --monitor to the init-l2-no-metrics target in crates/l2/Makefile.
  2. Run a Sequencer (I suggest make restart in crates/l2).
  3. Run the prover with make init-prover in crates/l2.
  4. Run make test in crates/l2.

Showcase

Overview

image

Logs

image

@ilitteri ilitteri self-assigned this Jun 30, 2025
@ilitteri ilitteri added the L2 Rollup client label Jun 30, 2025
Copy link

github-actions bot commented Jun 30, 2025

Lines of code report

Total lines added: 1668
Total lines removed: 0
Total lines changed: 1668

Detailed view
+------------------------------------------------------+-------+------+
| File                                                 | Lines | Diff |
+------------------------------------------------------+-------+------+
| ethrex/cmd/ethrex/l2/command.rs                      | 453   | +1   |
+------------------------------------------------------+-------+------+
| ethrex/cmd/ethrex/l2/initializers.rs                 | 123   | +17  |
+------------------------------------------------------+-------+------+
| ethrex/cmd/ethrex/l2/options.rs                      | 554   | +22  |
+------------------------------------------------------+-------+------+
| ethrex/crates/common/types/transaction.rs            | 2615  | +12  |
+------------------------------------------------------+-------+------+
| ethrex/crates/l2/based/sequencer_state.rs            | 32    | +1   |
+------------------------------------------------------+-------+------+
| ethrex/crates/l2/l2.rs                               | 11    | +1   |
+------------------------------------------------------+-------+------+
| ethrex/crates/l2/monitor/app.rs                      | 303   | +303 |
+------------------------------------------------------+-------+------+
| ethrex/crates/l2/monitor/mod.rs                      | 22    | +22  |
+------------------------------------------------------+-------+------+
| ethrex/crates/l2/monitor/utils.rs                    | 34    | +34  |
+------------------------------------------------------+-------+------+
| ethrex/crates/l2/monitor/widget/batches.rs           | 168   | +168 |
+------------------------------------------------------+-------+------+
| ethrex/crates/l2/monitor/widget/blocks.rs            | 151   | +151 |
+------------------------------------------------------+-------+------+
| ethrex/crates/l2/monitor/widget/chain_status.rs      | 200   | +200 |
+------------------------------------------------------+-------+------+
| ethrex/crates/l2/monitor/widget/l1_to_l2_messages.rs | 231   | +231 |
+------------------------------------------------------+-------+------+
| ethrex/crates/l2/monitor/widget/l2_to_l1_messages.rs | 248   | +248 |
+------------------------------------------------------+-------+------+
| ethrex/crates/l2/monitor/widget/mempool.rs           | 85    | +85  |
+------------------------------------------------------+-------+------+
| ethrex/crates/l2/monitor/widget/mod.rs               | 35    | +35  |
+------------------------------------------------------+-------+------+
| ethrex/crates/l2/monitor/widget/node_status.rs       | 73    | +73  |
+------------------------------------------------------+-------+------+
| ethrex/crates/l2/monitor/widget/tabs.rs              | 37    | +37  |
+------------------------------------------------------+-------+------+
| ethrex/crates/l2/sequencer/configs.rs                | 88    | +6   |
+------------------------------------------------------+-------+------+
| ethrex/crates/l2/sequencer/errors.rs                 | 276   | +7   |
+------------------------------------------------------+-------+------+
| ethrex/crates/l2/sequencer/mod.rs                    | 172   | +14  |
+------------------------------------------------------+-------+------+

@ilitteri ilitteri moved this to In Progress in ethrex_l2 Jul 2, 2025
@ilitteri ilitteri marked this pull request as ready for review July 7, 2025 15:38
@Copilot Copilot AI review requested due to automatic review settings July 7, 2025 15:38
@ilitteri ilitteri requested a review from a team as a code owner July 7, 2025 15:38
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a real‐time terminal monitor for the L2 sequencer, exposing metrics and chain state via a TUI.

  • Introduces a --monitor flag to enable the EthrexMonitor in the L2 sequencer.
  • Adds a new monitor module under crates/l2 with widgets, utils, and a terminal app (EthrexMonitor).
  • Extends RPC types and clients (block, mempool, eth client) to support monitoring (e.g., node_status, public fields).

Reviewed Changes

Copilot reviewed 34 out of 35 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/l2/sequencer/mod.rs Hook up start_monitor when cfg.monitor.enabled
crates/l2/monitor/widget/tabs.rs Defines tab state for the monitor UI
crates/l2/monitor/mod.rs Sets up start_monitor function and Clippy attributes
crates/l2/monitor/widget/blocks.rs Renders the latest L2 blocks table
crates/common/types/transaction.rs Changes serialized JSON field from "from" to "sender"
Comments suppressed due to low confidence (5)

crates/l2/monitor/widget/tabs.rs:4

  • Typo in enum name TabsSate; it should be TabsState to accurately reflect 'State'.
pub enum TabsSate {

crates/l2/monitor/widget/blocks.rs:145

  • [nitpick] Variable blob_bas is unclear; consider renaming to blob_gas or blob_size to match its meaning.
            .map(|(number, n_txs, hash, coinbase, gas, blob_bas, size)| {

crates/common/types/transaction.rs:278

  • Changing the JSON field from "from" to "sender" is a breaking change for any consumers; consider documenting this or bumping the serialization version.
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {

crates/common/types/transaction.rs:287

  • [nitpick] The error message format was corrected to include a colon. Ensure consistency across other error messages or add tests to cover this formatting.
    }

crates/l2/monitor/mod.rs:2

  • Rust lints use allow, warn, or denyexpect is not a recognized lint level. Replace #![expect(...)] with #![allow(clippy::expect_used)].
#![expect(clippy::expect_used)]

@ilitteri ilitteri moved this from In Progress to In Review in ethrex_l2 Jul 7, 2025
Copy link
Contributor

@tomip01 tomip01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! just some comments

@ilitteri ilitteri added this pull request to the merge queue Jul 10, 2025
Merged via the queue into main with commit 9dab7c0 Jul 10, 2025
36 checks passed
@ilitteri ilitteri deleted the based_monitor branch July 10, 2025 19:06
@github-project-automation github-project-automation bot moved this from In Review to Done in ethrex_l2 Jul 10, 2025
d-roak pushed a commit to 1sixtech/ethrex that referenced this pull request Jul 17, 2025
**Description**

This PR introduces de ethrex monitor. A currently optional tool for node
operators to monitor the L2 state.

The node can be monitored in two different tabs, the Overview tab and
the Logs tab. Both tabs have a help text line at the bottom to let know
the user how to interact with the current tab.

The Overview tab is composed of:
- An ASCII ethrex logo.
- A node status widget
- A general chain status widget, which lists:
    - Current batch (the batch being built by the Sequencer).
    - Current block (the block being built by the Sequencer).
    - Last committed batch.
    - Last committed block.
    - Last verified batch.
    - Last verified block.
- An L2 batches widget, which lists the last 50 L2 batches and their
current status, highlighting:
    - L2 batch number.
    - Number of blocks in the batch.
    - Number of L2 to L1 messages in the batch.
    - Commit tx hash (if committed).
    - Verify tx hash (if verified).
- An L2 blocks widget, which lists the last 50 L2 blocks, highlighting:
    - L2 block number.
    - Number of txs in the block.
    - L2 block hash.
    - L2 block coinbase (probably more relevant in based rollups).
    - Gas consumed.
    - Blob gas consumed.
    - Size of the block. 
- A mempool widget, which lists the current 50 txs in the memool,
highlighting:
    - Tx type (e.g. EIP1559, Privilege, etc).
    - Tx hash.
    - Tx sender.
    - Tx nonce.
- An L1 to L2 messages widget, which lists the last 50 L1 to L2 msgs and
their status, highlighting:
    - Message kind (e.g. deposit, message, etc).
    - Message status (e.g. Processed on L2, etc).
    - Message L1 tx hash.
    - Message L2 tx hash
    - Value
- An L2 to L1 messages widget, which lists the last 50 L2 to L1 msgs and
their status, highlighting:
    - Message kind (e.g. withdrawal, message, etc).
    - Message status (e.g. initiated, claimed, sent, delivered).
    - Receiver on L1.
    - Token L1 (if ERC20 withdrawal).
    - Token L2 (if ERC20 withdrawal).
    - L2 tx hash
    - Value

The Logs tab shows the logs altogether or by crate. The log level could
also be adjusted in runtime.

> [!NOTE]
> 1. This feature is introduced as optional for now given its initial
state. Once mature enough, it will be default for operators.
> 2. This initial version has some minor known flaws, but they were
skipped in this PR on purpose:
>     - lambdaclass#3512 .
>     - lambdaclass#3513.
>     - lambdaclass#3514.
>     - lambdaclass#3515.
>     - lambdaclass#3516.
>     - No optimizations were done.

**How to test**

1. Add `--monitor` to the `init-l2-no-metrics` target in
`crates/l2/Makefile`.
2. Run a Sequencer (I suggest `make restart` in `crates/l2`).
3. Run the prover with `make init-prover` in `crates/l2`.
4. Run `make test` in `crates/l2`.

**Showcase**

*Overview*

<img width="1512" alt="image"
src="https://github.com/user-attachments/assets/0431b1f3-1a8f-49cf-9519-413ea3d3ed1a"
/>

*Logs*

<img width="1512" alt="image"
src="https://github.com/user-attachments/assets/e0e6cdd7-1f8d-4278-8619-475cfaa14d4b"
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L2 Rollup client
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants